/*
	types.h
	Data types and structures used by Powerlink v1.1.0
*/


#ifndef POWERLINK_HEADER_TYPES
#define POWERLINK_HEADER_TYPES

#ifdef __GNUC__

#define PACKED __attribute__((__packed__))

typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
typedef unsigned char* PUINT8;
typedef unsigned short* PUINT16;
typedef unsigned int* PUINT32;
typedef signed char SINT8;
typedef signed short SINT16;
typedef signed int SINT32;
typedef signed char* PSINT8;
typedef signed short* PSINT16;
typedef signed int* PSINT32;

#endif

/*EP DLL types*/

struct PACKED MACHeader {
	UINT8 dmac[6];
	UINT8 smac[6];
	UINT16 etyp;
};

typedef struct MACHeader MACHeader;

struct PACKED EPDLLBasicHeader {
	UINT8 mtyp : 7;
	UINT8 : 1;
	UINT8 dest;
	UINT8 src;
};

typedef struct EPDLLBasicHeader EPDLLBasicHeader;

struct PACKED EPDLLSoCHeader {
	UINT8 mtyp : 7;
	UINT8 : 1;
	UINT8 dest;
	UINT8 src;
	UINT8 : 8;
	UINT8 : 6;
	UINT8 PS : 1;
	UINT8 MC : 1;
	UINT8 : 8;
	UINT8 time[8];
	UINT8 reltime[8];
	UINT8 reserved[24];
};

typedef struct EPDLLSoCHeader EPDLLSoCHeader;

struct PACKED EPDLLPReqHeader {
	UINT8 mtyp : 7;
	UINT8 : 1;
	UINT8 dest;
	UINT8 src;
	UINT8 : 8;
	UINT8 RD : 1;
	UINT8 : 1;
	UINT8 EA : 1;
	UINT8 : 2;
	UINT8 MS : 1;
	UINT8 : 2;
	UINT8 : 8;
	UINT8 pdov;
	UINT8 : 8;
	UINT16 size;
};

typedef struct EPDLLPReqHeader EPDLLPReqHeader;

struct PACKED EPDLLPResHeader {
	UINT8 mtyp : 7;
	UINT8 : 1;
	UINT8 dest;
	UINT8 src;
	UINT8 stat;
	UINT8 RD : 1;
	UINT8 : 3;
	UINT8 EN : 1;
	UINT8 MS : 1;
	UINT8 : 2;
	UINT8 RS : 3;
	UINT8 PR : 3;
	UINT8 : 2;
	UINT8 pdov;
	UINT8 : 8;
	UINT16 size;
};

typedef struct EPDLLPResHeader EPDLLPResHeader;

struct PACKED EPDLLSoAHeader {
	UINT8 mtyp : 7;
	UINT8 : 1;
	UINT8 dest;
	UINT8 src;
	UINT8 stat;
	UINT8 : 1;
	UINT8 ER : 1;
	UINT8 EA : 1;
	UINT8 : 5;
	UINT8 : 8;
	UINT8 svid;
	UINT8 svtg;
	UINT8 eplv;
	UINT8 reserved[37];
};

typedef struct EPDLLSoAHeader EPDLLSoAHeader;

struct PACKED EPDLLASndHeader {
	UINT8 mtyp : 7;
	UINT8 : 1;
	UINT8 dest;
	UINT8 src;
	UINT8 svid;
};

typedef struct EPDLLASndHeader EPDLLASndHeader;

union EPDLLHeader {
	EPDLLBasicHeader basichdr;
	EPDLLSoCHeader sochdr;
	EPDLLPReqHeader preqhdr;
	EPDLLPResHeader preshdr;
	EPDLLSoAHeader soahdr;
	EPDLLASndHeader asndhdr;
};

typedef union EPDLLHeader EPDLLHeader;

struct EPDLLBuffer {
	struct EPDLLBuffer* next;
	struct EPDLLBuffer* prev;
	MACHeader* machdr;
	EPDLLHeader* epdllhdr;
	PUINT8 data;
};

typedef struct EPDLLBuffer EPDLLBuffer;


#endif
